package Z.dailyExercise._0225;

public class _剑指Offer24反转链表 {
    /**
     * 自解：采取前后指针的方法
     * @param head
     * @return
     */

    public ListNode reverseList(ListNode head) {

        ListNode last = null;//以归入的最后一个结点
        ListNode now = head;//要归入的结点
        ListNode temp = null;

        while (now != null){
            temp = now.next;
            now.next = last;
            last = now;
            now = temp;
        }

        return last;
    }
}
